package com.mes.integration.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.Expose;
import com.mes.common.service.BasicService;
import com.mes.common.util.SysUtil;
import com.mes.integration.hbydMPM.impl.MpmImportService;
import com.mes.task.dao.iface.IOperationTaskDao;
import com.mes.task.dao.iface.IPartTaskDao;
import com.mes.task.domain.OperationTask;
import com.mes.task.manager.iface.IPartTaskManager;

@Service
public class MpmService extends BasicService<OperationTask> {

	@Autowired
	SysUtil sysUtil;
	@Autowired
	IOperationTaskDao operationTaskDao;
	@Autowired
	IPartTaskDao partTaskDao;
	@Autowired
	IPartTaskManager partTaskManager;
	@Autowired
	MpmImportService mpmImportService;

	@Expose
	public void syncMPMData() throws Exception {
		System.out.println("aaa");
		this.importLocalDataFile();
		System.out.println("bbb");
	}

	public String importLocalDataFile() {
		try{
			mpmImportService.importItemDataLocalFile("D:\\itemData.xml");
			return "数据同步完成！";
		}catch(Exception e){
			return e.toString();
		}
	}
	
	public String importFTPDataFile() {
		try{
			String remoteFilePath = sysUtil.getProperty("mpm.ftpItemDataFilePath");
			mpmImportService.importItemDataFile(remoteFilePath);
			return "数据同步完成！";
		}catch(Exception e){
			return e.toString();
		}
	}

	public String deleteFTPDataFile() throws Exception {
		try{
			String remoteFilePath = sysUtil.getProperty("mpm.ftpItemDataFilePath");
//			mpmImportService.deleteFile(remoteFilePath);
			return "文件删除完成！";
		}catch(Exception e){
			return e.toString();
		}
	}

}
